
/**
 * 表单提交
 */
function ajaxSubmit(form,succfunc) {
    layer.load();
    form.ajaxSubmit(function (text) {
        console.log(text);
        layer.closeAll('loading');
        var json = JSON.parse(text);
        if(json['code'] == '200'){
            layer.alert(json['msg'],{icon:1},function (index) {
                layer.close(index);
                succfunc(json);
            })
        }
        else{
            layer.alert(json['msg'],{icon:2});
        }
    });
}

/**
 * ajax通讯
 */
function ajax(url,data,succfunc) {
    layer.load();
    $.ajax({
        url:url
        ,type:'post'
        ,data:data
        ,success:function (res) {
            console.log(res);
            layer.closeAll('loading');
            var json = JSON.parse(res);
            if(json['code'] == '200'){
                layer.alert(json['msg'],{icon:1},function (index) {
                    layer.close(index);
                    succfunc(json);
                })
            }
            else{
                layer.alert(json['msg'],{icon:2});
            }
        }
        ,error:function (res) {
            layer.closeAll('loading');
            layer.alert('网络错误',{icon:2});
        }
    });
}